<!DOCTYPE html>
<html>
<head>
	{include file="common_header" /}
	{include file="common_top" /}
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">修改模块</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">
          <div class="layui-form-item">
            <label class="layui-form-label">上级模块</label>
            <div class="layui-input-block">
              <select name="sid" id="sid">
                <option value="0">==顶级模块==</option>
				{volist name="list" id="vo"}
                <option value="{$vo.mo_id}" {if $info['mo_sid']==$vo.mo_id}selected="selected"{/if}>{$vo.mo_title}</option>
				{/volist}
              </select>
            </div>
          </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label">模块名称</label>
            <div class="layui-input-block">
              <input type="text" name="title" id="title"   placeholder="模块名称" class="layui-input" value="{$info['mo_title']}">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">简写名称</label>
            <div class="layui-input-block">
              <input type="text" name="shorttitle" id="shorttitle"   placeholder="简写名称" class="layui-input" value="{$info['mo_shorttitle']}">
            </div>
          </div>
		  
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">控制器</label>
            <div class="layui-input-block">
              <input type="text" name="controller" id="controller"   placeholder="控制器" class="layui-input" value="{$info['mo_controller']}">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">方法</label>
            <div class="layui-input-block">
              <input type="text" name="action" id="action"   placeholder="方法" class="layui-input" value="{$info['mo_action']}">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
              <input type="text" name="sort" id="sort"   placeholder="排序" class="layui-input" value="{$info['mo_sort']}">
            </div>
          </div>
		  

          <div class="layui-form-item">
            <label class="layui-form-label">可用导航显示</label>
            <div class="layui-input-block">
              <input type="radio" name="show" value="0" title="不显示"  {if $info['mo_show']==0}checked{/if}>
              <input type="radio" name="show" value="1" title="显示"  {if $info['mo_show']==1}checked{/if}>
            </div>
          </div>       
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <div class="layui-btn sub">立即提交</div>
                <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{include file="common_footer" /} 
<script>
$(".sub").click(function(){
	//if(!$(".btn").hasClass("sub")){return false;}
	var sid        = $("#sid").val();
	var title      = $("#title").val();
	var shorttitle = $("#shorttitle").val();
	var controller = $("#controller").val();
	var action     = $("#action").val();
	var sort       = $("#sort").val();
	var show       = $("input[name='show']:checked").val();
	var navplace   = 1;


	if(title == ""){
		show_error("{$language['model_empty_title']}");
		return false
	}
	
	if(shorttitle == ""){
		show_error("{$language['model_empty_shorttitle']}");
		return false
	}
	
	if(controller == ""){
		show_error("{$language['model_empty_controller']}");
		return false
	}
	
	if(action == ""){
		show_error("{$language['model_empty_action']}");
		return false
	}
	
	if(sort == ""){
		sort = 999;
	}

	$.ajax({
		type:"POST",
		url:"{:url('model/edit')}",
		dataType:"json",
		data:{
			id:{$info['mo_id']},
			sid:sid,
			title:title,
			shorttitle:shorttitle,
			controller:controller,
			action:action,
			sort:sort,
			show:show,
			navplace:navplace,
		},
		success:function(res){
			if(res.status == "success"){
				show_toast_callurl(res.data,"{:url('model/index')}","success");
			}else{
				show_error(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
</body>
</html>
